<template>
  <div>
    <van-nav-bar
      :title="$route.name"
      @click-left="$router.back()"
      left-text="返回"
      left-arrow
    />

    <div>
      <van-address-list
        v-model="chosenAddressId"
        :list="addresslist"
        :disabled-list="disabledList"
        disabled-text="以下地址超出配送范围"
        default-tag-text="默认"
        @add="onAdd"
        @edit="onEdit" />
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant';
import { mapGetters, mapActions } from 'vuex'
import { addressList, addressEdit } from '../request/api'

export default {
  data() {
    return {
      chosenAddressId: 1,
      temp: [],
      
      disabledList: [
        {
          id: '3',
          name: '王五',
          tel: '1320000000',
          address: '浙江省杭州市滨江区江南大道 15 号',
        },
      ],
    };
  },
  computed: {
    ...mapGetters({
      addresslist: 'getAddressList'
    })
  },
  methods: {
    onAdd() {
      this.$router.push("/addressedit");
    },
    onEdit(item, index) {
      this.$router.push({
        path:'/addressedit',
        query:{
          id:item.id
        }
      })
    },
      ...mapActions({
        getAddressAction: 'getAddressAction'
      })
  },
  mounted() {
    this.getAddressAction()

     // addressList({
     //   uid: this.$store.getters.getUser.uid
     // }).then(res => {
     //   if(res.data.code == 200) {
     //     this.temp = res.data.list
     //     this.temp.map(item => {
     //       let { id, username:name, userphone:tel, location, useraddress} = item
     //       let i = { id,name,tel,address:location+useraddress,isDefault:true}
     //       this.list.push(i)
     //     })
     //   }
     // })
  }
};
</script>

<style scoped></style>
